import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";

const routes: Array<RouteRecordRaw> = [
  //首页
  {
    path: "/",
    name: "Home",
    component: () => import("@/views/home/index.vue"),
  },
  //去详情
  {
    path: "/detail",
    name: "Detail",
    component: () => import("@/views/detail/index.vue"),
    meta: {
      hidden: true,
    },
  },
  {
    path: "/sort",
    name: "Sort",
    component: () => import("@/views/sort/index.vue"),
    meta: {
      hidden: false,
    },
  },
  {
    path: "/list",
    name: "List",
    component: () => import("@/views/list/index.vue"),
    meta: {
      hidden: false,
    },
  },
  //搜索
  {
    path: "/search",
    name: "Search",
    component: () => import("@/views/search/index.vue"),
    meta: {
      hidden: false,
    },
  },
  //购物车
  {
    path: "/cart",
    name: "Cart",
    component: () => import("@/views/cart/index.vue"),
    meta: {
      hidden: false,
    }
  },
  //结算
  {
    path: '/settlement',
    name: 'Settlement',
    component: () => import('@/views/settlement/index.vue'),
    meta: { 
      hidden:false
    },
  },
  //地址
  {
    path: "/contactList",
    name: "Contactlist",
    component: () => import("@/views/contactList/index.vue"),
    meta: {
      hidden: false,
    },
  },
  {
    path: "/worthbuy",
    name: "Worthbuy",
    component: () => import("@/views/worthbuy/index.vue"),
    meta: {
      hidden: false,
    },
  },
  {
    path: "/chaozhi",
    name: "Chaozhi",
    component: () => import("@/views/worthbuy/components/chaozhi/chaozhi.vue"),
    meta: {
      hidden: false,
    },
  },
  ,
  {
    path: "/shaidan",
    name: "Shaidan",
    component: () => import("@/views/worthbuy/components/shaidan/index.vue"),
    meta: {
      hidden: false,
    },
  },
  {
    path: "/personal",
    name: "Personal",
    component: () => import("@/views/personal/index.vue"),
    meta: {
      hidden: true,
    },
  },
  {
    path: "/login",
    name: "Login",
    component: () => import("@/views/login/login/index.vue"),
  },
  {
    path: "/goiphone",
    name: "Goiphone",
    component: () => import("@/views/login/goiphone/index.vue"),
  },
  {
    path: "/gophone",
    name: "Gophone",
    component: () => import("@/views/login/gophone/index.vue"),
  },
  {
    path: "/gomail",
    name: "Gomail",
    component: () => import("@/views/login/gomail/index.vue"),
  },
  {
    path: "/register",
    name: "Reguster",
    component: () => import("@/views/login/register/index.vue"),
  },


  //404页面
  {
    path: "/404",
    name: "404",
    component: () => import("@/views/error/404.vue"),
    meta: {
      hidden: true,
    },
  },
];

export const anyRoute = {
  path: "/:pathMatch(.*)",
  name: "Any",
  redirect: "/404",
  meta: {
    hidden: true,
  },
};

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
  //跳转固定到top 0
  scrollBehavior() {
    return {
      top: 0,
    };
  },
});

export default router;
